﻿using System;
using System.Runtime.InteropServices;
using UnityEngine;

[Serializable, StructLayout(LayoutKind.Sequential)]
public struct NetworkPosition
{
    public short x_100;
    public sbyte y_10;
    public short z_100;
    public NetworkPosition(float x, float y, float z)
    {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public float x
    {
        get
        {
            return (((float) this.x_100) / 100f);
        }
        set
        {
            this.x_100 = (short) (value * 100f);
        }
    }
    public float y
    {
        get
        {
            return (((float) this.y_10) / 10f);
        }
        set
        {
            this.y_10 = (sbyte) (value * 10f);
        }
    }
    public float z
    {
        get
        {
            return (((float) this.z_100) / 100f);
        }
        set
        {
            this.z_100 = (short) (value * 100f);
        }
    }
    public override string ToString()
    {
        return string.Format("({0},{1},{2})", this.x, this.y, this.z);
    }

    public static implicit operator Vector3(NetworkPosition v)
    {
        return new Vector3(v.x, v.y, v.z);
    }

    public static implicit operator NetworkPosition(Vector3 v)
    {
        return new NetworkPosition(v.x, v.y, v.z);
    }
}

